<%@page import="com.party.core.model.system.TargetType" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>账户中心</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <link rel="stylesheet" href="${ctx}/css/ui/system/main/main.css">
    <%@include file="../include/commonFile.jsp" %>
    <style type="text/css">
        .expire-tip {
            background-color: #ffffcc;
            padding: 15px 30px;
            line-height: 24px;
        }

        .expire-tip .tip-text {
            display: inline-block;
        }

        .expire-tip .tip-opt {
            display: inline-block;
            margin-left: 50px;
            vertical-align: top;
        }
    </style>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <c:if test="${showExpire}">
            <div class="expire-tip">
                <div class="tip-text">
                    <c:if test="${!isExpire}">
                        <p>
                            您的账户还有${expirationDay}就到期了，到期后，已经报名的用户可以访问和继续众筹，新用户无法报名
                        </p>
                    </c:if>
                    <c:if test="${isExpire}">
                        <p>
                            您的账户已到期，已经报名的用户可以访问和继续众筹，新用户无法报名
                        </p>
                    </c:if>
                    <p>官方咨询电话：4008-771-663</p>
                </div>
                <c:if test="${!isChildAccount}">
                    <div class="tip-opt">
                        <a href="${ctx}/serviceOrder/info.do" target="_self"
                           class="layui-btn layui-btn-danger layui-btn-sm ml10">立即续费</a>
                    </div>
                </c:if>
            </div>
        </c:if>
        <div class="section-main">
            <div class="head-main-car">
                <div class="info-box bg-green">
                    <div class="box-content " id="allApply-num">
                        <div class="box-icon">
                            <i class="iconfont icon-friendadd btn-icon"></i>
                        </div>
                        <div class="box-inner">
                            <div class="num"> ${map.history_old.mmCount.applyNum}</div>
                            <div class="info">所有报名数</div>
                        </div>
                    </div>
                </div>
                <div class="info-box bg-orange">
                    <div class="box-content " id="order-num">
                        <div class="box-icon">
                            <i class="iconfont icon-form btn-icon"></i>
                        </div>
                        <div class="box-inner">
                            <div class="num">${map.history_old.mmCount.orderNum}</div>
                            <div class="info">所有订单数</div>
                        </div>
                    </div>
                </div>
                <div class="info-box bg-red">
                    <div class="box-content " id="member-num">
                        <div class="box-icon">
                            <i class="iconfont icon-group btn-icon"></i>
                        </div>
                        <div class="box-inner">
                            <div class="num">${ map.history_old.mmCount.memberNum}</div>
                            <div class="info">所有注册会员数</div>
                        </div>
                    </div>
                </div>
                <div class="info-box bg-blue">
                    <div class="box-content ">
                        <div class="box-icon">
                            <i class="iconfont icon-moneybag btn-icon"></i>
                        </div>
                        <div class="box-inner">
                            <div class="num"><fmt:formatNumber value="${map.total.mmCount.money}" pattern="0.00"/></div>
                            <div class="info">所有资金数</div>
                        </div>
                    </div>
                </div>
                <div class="info-box bg-light-blue">
                    <div class="box-content ">
                        <div class="box-icon">
                            <i class="iconfont icon-footprint btn-icon"></i>
                        </div>
                        <div class="box-inner">
                            <div class="num">${map.history_old.mmCount.viewNum}</div>
                            <div class="info">所有访问数</div>
                        </div>
                    </div>
                </div>
            </div>
            <%@include file="../system/member/memberIndex.jsp" %>
            <div class="list-content">
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col width="100">
                            <col width="100">
                            <col width="100">
                            <col width="100">
                            <col width="100">
                            <col width="100">
                            <col width="100">
                            <col width="100">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>数据</th>
                            <th>社群总人数</th>
                            <th>有效会员</th>
                            <th>活跃人数</th>
                            <th>自组织活跃数</th>
                            <th>推荐会员数</th>
                            <th>行业数</th>
                            <th>总规模(单位:万元)</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>
                                今日
                            </td>
                            <td>
                                ${map.today.cdcOutput.memberTotal}
                            </td>
                            <td>
                                ${map.today.cdcOutput.effectiveMemberNum}
                            </td>
                            <td>
                                ${map.today.cdcOutput.activeMemberNum}
                            </td>
                            <td>
                                ${map.today.cdcOutput.jobActiveMemberNum}
                            </td>
                            <td>
                                ${map.today.cdcOutput.recommendMemberNum}
                            </td>
                            <td>
                                ${map.today.cdcOutput.industryNum}
                            </td>
                            <td>
                                <fmt:formatNumber value="${map.today.cdcOutput.companyMoney}" pattern="0.00"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                昨日
                            </td>
                            <td>
                                ${map.yesterday.cdcOutput.memberTotal}
                            </td>
                            <td>
                                ${map.yesterday.cdcOutput.effectiveMemberNum}
                            </td>
                            <td>
                                ${map.yesterday.cdcOutput.activeMemberNum}
                            </td>
                            <td>
                                ${map.yesterday.cdcOutput.jobActiveMemberNum}
                            </td>
                            <td>
                                ${map.yesterday.cdcOutput.recommendMemberNum}
                            </td>
                            <td>
                                ${map.yesterday.cdcOutput.industryNum}
                            </td>
                            <td>
                                <fmt:formatNumber value="${map.yesterday.cdcOutput.companyMoney}" pattern="0.00"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                前日
                            </td>
                            <td>
                                ${map.beforeYDay.cdcOutput.memberTotal}
                            </td>
                            <td>
                                ${map.beforeYDay.cdcOutput.effectiveMemberNum}
                            </td>
                            <td>
                                ${map.beforeYDay.cdcOutput.activeMemberNum}
                            </td>
                            <td>
                                ${map.beforeYDay.cdcOutput.jobActiveMemberNum}
                            </td>
                            <td>
                                ${map.beforeYDay.cdcOutput.recommendMemberNum}
                            </td>
                            <td>
                                ${map.beforeYDay.cdcOutput.industryNum}
                            </td>
                            <td>
                                <fmt:formatNumber value="${map.beforeYDay.cdcOutput.companyMoney}" pattern="0.00"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                本周
                            </td>
                            <td>
                                ${map.week.cdcOutput.memberTotal}
                            </td>
                            <td>
                                ${map.week.cdcOutput.effectiveMemberNum}
                            </td>
                            <td>
                                ${map.week.cdcOutput.activeMemberNum}
                            </td>
                            <td>
                                ${map.week.cdcOutput.jobActiveMemberNum}
                            </td>
                            <td>
                                ${map.week.cdcOutput.recommendMemberNum}
                            </td>
                            <td>
                                ${map.week.cdcOutput.industryNum}
                            </td>
                            <td>
                                <fmt:formatNumber value="${map.week.cdcOutput.companyMoney}" pattern="0.00"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                本月
                            </td>
                            <td>
                                ${map.month.cdcOutput.memberTotal}
                            </td>
                            <td>
                                ${map.month.cdcOutput.effectiveMemberNum}
                            </td>
                            <td>
                                ${map.month.cdcOutput.activeMemberNum}
                            </td>
                            <td>
                                ${map.month.cdcOutput.jobActiveMemberNum}
                            </td>
                            <td>
                                ${map.month.cdcOutput.recommendMemberNum}
                            </td>
                            <td>
                                ${map.month.cdcOutput.industryNum}
                            </td>
                            <td>
                                <fmt:formatNumber value="${map.month.cdcOutput.companyMoney}" pattern="0.00"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                历史
                            </td>
                            <td>
                                ${map.history.cdcOutput.memberTotal}
                            </td>
                            <td>
                                ${map.history.cdcOutput.effectiveMemberNum}
                            </td>
                            <td>
                                ${map.history.cdcOutput.activeMemberNum}
                            </td>
                            <td>
                                ${map.history.cdcOutput.jobActiveMemberNum}
                            </td>
                            <td>
                                ${map.history.cdcOutput.recommendMemberNum}
                            </td>
                            <td>
                                ${map.history.cdcOutput.industryNum}
                            </td>
                            <td>
                                <fmt:formatNumber value="${map.history.cdcOutput.companyMoney}" pattern="0.00"/>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="page_content" class="page-container"></div>

            <form class="layui-form" method="post">
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item">
                                <label class="search-form-lable">数据</label>
                                <div class="check-btn-inner">
                                    <a href="javascript:void(0);" onclick="submit($(this),0)">社群总人数</a>
                                    <a href="javascript:void(0);" onclick="submit($(this),1)" class="active">有效会员</a>
                                    <a href="javascript:void(0);" onclick="submit($(this),2)">活跃人数</a>
                                    <a href="javascript:void(0);" onclick="submit($(this),3)">自组织活跃数</a>
                                    <a href="javascript:void(0);" onclick="submit($(this),4)">推荐会员数</a>
                                    <a href="javascript:void(0);" onclick="submit($(this),5)">行业数</a>
                                    <a href="javascript:void(0);" onclick="submit($(this),6)">总规模(单位:万元)</a>
                                    <input type="hidden" name="type" id="type" value=""/>
                                </div>
                                <div class="cl"></div>
                            </li>
                            <li class="form-item">
                                <label class="search-form-lable">时间</label>
                                <div class="layui-input-inline">
                                    <select id="length" name="length" lay-filter="length">
                                        <option value="7">最近7天</option>
                                        <option value="15">最近15天</option>
                                        <option value="30" selected>最近30天</option>
                                        <option value="0">最近12周</option>
                                        <option value="-1">最近12月</option>
                                    </select>
                                </div>
                                <div class="cl"></div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="content" id="charts" style="height:400px;"></div>


            <form class="layui-form" method="post">
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item">
                                <label class="search-form-lable">数据</label>
                                <div class="check-btn-inner">
                                    <a href="javascript:void(0);" onclick="cSubmit($(this),0)" class="active">社群总览</a>
                                    <a href="javascript:void(0);" onclick="cSubmit($(this),1)">参与度分析</a>
                                    <a href="javascript:void(0);" onclick="cSubmit($(this),2)">用户分析</a>
                                    <input type="hidden" name="cType" id="cType" value=""/>
                                </div>
                                <div class="cl"></div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="list-content">
                <div class="cl">
                    <table class="layui-table" id="indexTab">
                        <colgroup>
                        </colgroup>
                        <thead>
                        <tr>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
    <!-- 短信配置 -->
    <div id="settingsDialog" style="display: none;">
        <form class="layui-form p20" method="post" action="">
            <input type="hidden" name="memberId" value="${member.id}"/>
            <input type="hidden" name="type" value="PUSH_SMS"/>
            <div class="layui-form-item" style="margin-bottom: 0px">
                <div class="layui-inline" style="margin-right: 0px; margin-bottom: 0px">
                    <div class="layui-input-inline" style="width: 260px!important; margin-right: 0px">
                        <span style="height: 38px; line-height: 38px">短信数量低于</span>
                        <input type="number" min="1" max="100" name="warnNum" autocomplete="off" class="layui-input"
                               style="display: inline-block; width: 100px"/>
                        <span style="height: 38px; line-height: 38px">%时预警</span>
                    </div>
                </div>
            </div>
        </form>
    </div>

    <div id="editInfoDiv" style="display: none;margin: 20px auto">
        <div style="text-align: center; font-size: 18px;">
            <span class="title">账号设置</span>
        </div>
        <form class="layui-form p20" id="editInfoFrom" method="post" action="">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 70px">头像<span class="f-verify-red">*</span></label>
                <div class="cover-content">
                    <input type="hidden" name="logo" id="pic"
                           value="http://txzapp-10052192.image.myqcloud.com/1490783498894"/>
                    <span id="cover-img" class="round-img"
                          style="width: 60px;height: 60px; background-image:url(http://txzapp-10052192.image.myqcloud.com/1490783498894)"></span>
                    <a class="layui-btn layui-btn-danger" id="sel_pic_img">+上传</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 70px">昵称<span class="f-verify-red">*</span></label>
                <div class="layui-input-inline">
                    <input class="layui-input" maxlength="14" name="realname"
                           placeholder="请输入您的系统昵称" value='' style="width:280px;"/>
                </div>
            </div>
            <button type="button" id="butRg" class="layui-btn layui-btn-danger "
                    style="width: 180px;margin: 30px 50px 0px 130px;">
                完成
            </button>
        </form>
    </div>

    <div id="expire_dialog" style="display: none;">
        <div class="f-dialog-shadow"></div>
        <div class="f-dialog-content">
            <div class="dialog-header">
                <div class="title"><span></span></div>
                <span class="close-icon"></span></div>
            <div class="dialog-detail">
                <div class="content">
                    <div>
                        <div class="mb10"><i class="iconfont icon-info expire-tip-icon"></i>
                            <p class="expire-tip-text">提示</p></div>
                        <div class="expire-tip-desc"><p>续费后即可使用系统，赶紧联系我们吧！</p>
                            <p>官方咨询电话：4008-771-663</p></div>
                        <div><a
                                href="/web/serviceOrder/info.do" class="layui-btn layui-btn-danger"
                                style="width: 200px">立即续费</a></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript" src="${ctx}/static/echarts-3.0/echarts.min.js"></script>
<script type="text/javascript" src="${ctx}/static/echarts-3.0/base_config.js"></script>
<script type="text/javascript">
    var isEditInfo = ${isEditInfo};
    var systemType = ${systemType};
    var isChildAccount = ${isChildAccount}
        $(function () {
            layui.use(['form', 'laydate'], function () {
                form = layui.form, laydate = layui.laydate;
                form.on('select(length)', function (data) {
                    var type = $("#type").val();
                    var length = data.value;
                    getData(type, length);
                });
                if (isEditInfo == 0) {
                    var index = layer.open({
                        type: 1,
                        area: ['480px', '320px'],
                        title: '',
                        content: $("#editInfoDiv"),
                        scrollbar: true,
                        closeBtn: 0
                    });
                }
                if (isEditInfo == 1 && systemType == 0 && !isChildAccount) {
                    var index = layer.open({
                        type: 1,
                        area: ['480px', '320px'],
                        title: '',
                        content: $("#expire_dialog"),
                        scrollbar: true,
                        closeBtn: 0
                    });
                }
            });
            $('#sel_pic_img').click(function () {
                txz.openSelImg({
                    min: 1,
                    max: 1,
                    info: '建议尺寸：120x120',
                    type: '<%=TargetType.LOGO.getCode()%>',
                    cb: function (imgs) {
                        $('#cover-img').css('background-image', 'url(' + imgs[0].path + ')');
                        $('#pic').val(imgs[0].path);
                    }
                })
            })
            $('#butRg').click(function () {

                var msg = "";
                var logo = $("#editInfoDiv [name=logo]").val();
                if (logo == "") {
                    msg = "请选择头像";
                }
                var realname = $("#editInfoDiv [name=realname]").val();
                if (realname == "") {
                    msg = "昵称不能为空";
                }

                if (msg != "") {
                    util.layerMsgError(msg);
                    return null;
                }

                var index = layer.load(1);
                $.post("${ctx}/user/register/updatePartnerMember.do", $("#editInfoDiv form").serializeArray(), function (ret) {
                    layer.close(index);
                    if (ret.success == true) {
                        util.layerMsgSuccess(ret.description, function () {
                            location.reload();
                        });
                    } else {
                        util.layerMsgError(ret.description);
                    }
                });
            })
        });

    function getData(type, length) {
        $.get('${ctx}/merchant/analyze/community/chart.do',
            {type: type, length: length},
            function (res) {
                var charts = echarts.init(document.getElementById('charts'));

                var option = {
                    title: {
                        text: '数据趋势图',
                    },
                    xAxis: {
                        data: res.data.dateList
                    },
                    series: [{
                        name: '数据量',
                        type: 'line',
                        data: res.data.dataList,
                    }]
                };
                option = getEchartBaseLineOpt(option);
                charts.setOption(option);
            })
    }

    getData('', '');

    function submit(obj, value) {
        $(obj).parent(".check-btn-inner").find("a").removeClass("active");
        $(obj).addClass("active");
        $(obj).parent(".check-btn-inner").find("[type=hidden]").val(value);
        var type = $("#type").val();
        var length = $("#length").val();
        getData(type, length);
    }

    getCData('0');

    function getCData(cType) {
        $.get('${ctx}/merchant/analyze/community/indexTab.do',
            {cType: cType},
            function (res) {
                $('#indexTab colgroup').html("")
                $('#indexTab thead tr').html("")
                $('#indexTab tbody').html("")
                var cQueryTypes_var = res.data.cQueryTypes;
                var dataList_var = res.data.dataList;

                $('#indexTab colgroup').append('<col width="120">')
                $('#indexTab thead tr').append('<th>' + '社群名称' + '</th>')
                for (var i = 0; i < cQueryTypes_var.length; i++) {
                    $('#indexTab colgroup').append('<col width="120">')
                    $('#indexTab thead tr').append('<th>' + cQueryTypes_var[i] + '</th>')
                }

                for (var j = 0; j < dataList_var.length; j++) {
                    if (cType == 0) {
                        $('#indexTab tbody').append(
                            '<tr><td>' + dataList_var[j].memberGroupName.replace("行知公社","平台主体") + '</td><td>' + dataList_var[j].memberTotal + '</td><td>' + dataList_var[j].effectiveMemberNum + '</td><td>'
                            + dataList_var[j].activeMemberNum + '</td><td>' + dataList_var[j].jobActiveMemberNum + '</td><td>' + dataList_var[j].recommendMemberNum + '</td><td>' +
                            dataList_var[j].industryNum + '</td><td>' + dataList_var[j].companyMoney + '</td></tr>')
                    } else if (cType == 1) {
                        $('#indexTab tbody').append(
                            '<tr><td>' + dataList_var[j].memberGroupName.replace("行知公社","平台主体") + '</td><td>' + dataList_var[j].pubActivityNum + '</td><td>' + dataList_var[j].commonwealScore + '</td><td>'
                            + dataList_var[j].dedicationScore + '</td><td>' + dataList_var[j].studyScore + '</td><td>' + dataList_var[j].visitNum +'</td></tr>')
                    } else {
                        $('#indexTab tbody').append(
                            '<tr><td>' + dataList_var[j].memberGroupName.replace("行知公社","平台主体") + '</td><td>' + dataList_var[j].gobiActNum + '</td><td>' + dataList_var[j].exerciseDuration + '</td><td>'
                            + dataList_var[j].religionCount + '</td><td>'+ dataList_var[j].avgAgeNum + '</td></tr>')
                    }
                }
            })
    }

    function cSubmit(obj, value) {
        $(obj).parent(".check-btn-inner").find("a").removeClass("active");
        $(obj).addClass("active");
        $(obj).parent(".check-btn-inner").find("[type=hidden]").val(value);
        var type = $("#cType").val();
        getCData(type);
    }
</script>
</body>
</html>